#ifndef STAT_H
#define STAT_H

#include <QList>
class Stat
{
public:
    Stat();
    void add(qreal data);
    qreal getMin() const {return m_min;}
    qreal getMax() const {return m_max;}
    qreal getSum() const {return m_sum;}
    bool isEmpty() const {return m_values.isEmpty();}
    qint64 nrOfPosts() const {return m_values.size();}
    qreal getAverage() const {return m_sum / (qreal)m_values.size();}
    qreal at(int idx); // return value att index idx, else return 0

    void recalcSum(); // recalculate the sum. This will add the items, starting with the smallest, to minimize numerical errors
private:
    qreal m_sum,m_max,m_min;
    QList<qreal> m_values;
};

#endif // STAT_H
